<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ch="http://java.sun.com/jsf/composite/channel"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="content">

        <h:form>

            <p:panel header="Statement Of Agent Account Total And Count">
                <f:facet name="header">
                    <p:outputLabel value="Agent Wise Appoinment Totals And Count" />
                    <p:commandButton id="btnBack" value="Back" 
                                     action="/channel/channel_reports" style="float: right;"
                                     ajax="false">
                    </p:commandButton>
                </f:facet>

                <p:panel>
                    <h:panelGrid columns="2" >
                        <h:outputLabel value="From Date"/>
                        <p:calendar value="#{channelReportTempController.fromDate}" navigator="true" pattern="dd MMM yyyy HH:mm:ss"  >
                        </p:calendar>
                        <h:outputLabel value="To Date"/>
                        <p:calendar value="#{channelReportTempController.toDate}" navigator="true" pattern="dd MMM yyyy HH:mm:ss" >
                        </p:calendar>

                    </h:panelGrid> 
                    <h:panelGrid columns="2" id="pg1" >
                        <h:outputLabel value="Count"/> 
                        <p:selectBooleanCheckbox value="#{channelReportTempController.count}" >
                            <p:ajax event="change" process="@this" update="pan1 pan2 :#{p:component('pan3')} pg1 " />
                        </p:selectBooleanCheckbox>
                        <h:outputLabel value="By Date"/> 
                        <p:selectBooleanCheckbox value="#{channelReportTempController.byDate}" />
                        <h:outputLabel value="Only Billed Agencies"/> 
                        <p:selectBooleanCheckbox value="#{channelReportTempController.billedAgencys}" />
                        <h:outputLabel value="Without Doc Fee" rendered="#{!channelReportTempController.count}"/> 
                        <p:selectBooleanCheckbox value="#{channelReportTempController.withOutDocPayment}" rendered="#{!channelReportTempController.count}" />
                    </h:panelGrid> 
                    <h:panelGrid columns="3">
                        <h:panelGroup id="pan1">
                            <h:panelGrid columns="2" rendered="#{channelReportTempController.count}" >
                                <p:commandButton action="#{channelReportTempController.createAgentWiseAppoinmentCount()}" value="Count" ajax="false" />
                            </h:panelGrid>
                        </h:panelGroup>
                        <h:panelGroup id="pan2">
                            <h:panelGrid columns="2" rendered="#{!channelReportTempController.count}" >
                                <p:commandButton action="#{channelReportTempController.createAgentWiseAppoinmentTotal()}" value="Totals" ajax="false" />
                            </h:panelGrid>
                        </h:panelGroup>
                        <p:commandButton ajax="false" value="Print" styleClass="noPrintButton">
                            <p:printer target="reportPrint"  />
                        </p:commandButton>
                    </h:panelGrid> 
                </p:panel>
                <p:panel id="reportPrint" styleClass="noBorder summeryBorder">
                    <p:dataTable value="#{channelReportTempController.channelSummeryDateRangeBillTotalTables}" var="s" id="tbl1" >
                        <f:facet name="header">
                            <p:outputLabel value="#{sessionController.loggedUser.institution.name}" />
                            <br></br>
                            <p:outputLabel value="Agent Wise Appoinment " />
                            <h:panelGroup id="pan3">
                                <p:outputLabel value="(Totals)" rendered="#{!channelReportTempController.count}" />
                                <p:outputLabel value="(Count)" rendered="#{channelReportTempController.count}" />
                            </h:panelGroup>
                            <br></br>
                            <p:outputLabel value="From : " />
                            <p:outputLabel value="#{channelReportTempController.fromDate}" >
                                <f:convertDateTime pattern="MMMM yyyy" />
                            </p:outputLabel>
                            <p:outputLabel value="  To : " />
                            <p:outputLabel value="#{channelReportTempController.toDate}" >
                                <f:convertDateTime pattern="MMMM yyyy" />
                            </p:outputLabel>
                        </f:facet>
                        <p:columnGroup type="header" >
                            <p:row>
                                <p:column headerText="Month" />
                                <p:column headerText="Billed" />
                                <p:column headerText="Cancel" />
                                <p:column headerText="Refund" />
                                <p:column headerText="Total" />
                            </p:row>
                        </p:columnGroup>
                        <p:subTable value="#{s.channelSummeryDateRangeBillTotalRows}" var="a" >
                            <f:facet name="header">
                                <p:outputLabel value="#{s.agency.name} - (#{s.agency.institutionCode})" >
                                </p:outputLabel>
                            </f:facet>
                            <p:column>
                                <p:outputLabel value="#{a.date}" style="#{a.bold ? 'font-weight: bold':''}" >
                                </p:outputLabel>
                            </p:column>
                            <p:column styleClass="numberCol" rendered="#{channelReportTempController.count}">
                                <p:outputLabel value="#{a.billTotal}" style="#{a.bold ? 'font-weight: bold':''}" >
                                    <f:convertNumber pattern="##,##,##0" />
                                </p:outputLabel>
                            </p:column>
                            <p:column styleClass="numberCol" rendered="#{channelReportTempController.count}">
                                <p:outputLabel value="#{a.canceledTotal}" style="#{a.bold ? 'font-weight: bold':''}" >
                                    <f:convertNumber pattern="##,##,##0" />
                                </p:outputLabel>
                            </p:column>
                            <p:column styleClass="numberCol" rendered="#{channelReportTempController.count}">
                                <p:outputLabel value="#{a.refundTotal}" style="#{a.bold ? 'font-weight: bold':''}" >
                                    <f:convertNumber pattern="##,##,##0" />
                                </p:outputLabel>
                            </p:column>
                            <p:column styleClass="numberCol" rendered="#{channelReportTempController.count}" >
                                <p:outputLabel value="#{a.billTotal-(a.canceledTotal+a.refundTotal)}" style="#{a.bold ? 'font-weight: bold':''}" >
                                    <f:convertNumber pattern="##,##,##0" />
                                </p:outputLabel>
                            </p:column>
                            <p:column styleClass="numberCol" rendered="#{!channelReportTempController.count}">
                                <p:outputLabel value="#{a.billTotal}" style="#{a.bold ? 'font-weight: bold':''}" >
                                    <f:convertNumber pattern="##,##,##0.00" />
                                </p:outputLabel>
                            </p:column>
                            <p:column styleClass="numberCol" rendered="#{!channelReportTempController.count}">
                                <p:outputLabel value="#{a.canceledTotal}" style="#{a.bold ? 'font-weight: bold':''}" >
                                    <f:convertNumber pattern="##,##,##0.00" />
                                </p:outputLabel>
                            </p:column>
                            <p:column styleClass="numberCol" rendered="#{!channelReportTempController.count}">
                                <p:outputLabel value="#{a.refundTotal}" style="#{a.bold ? 'font-weight: bold':''}" >
                                    <f:convertNumber pattern="##,##,##0.00" />
                                </p:outputLabel>
                            </p:column>
                            <p:column styleClass="numberCol" rendered="#{!channelReportTempController.count}" >
                                <p:outputLabel value="#{a.billTotal+a.canceledTotal+a.refundTotal}" style="#{a.bold ? 'font-weight: bold':''}" >
                                    <f:convertNumber pattern="##,##,##0.00" />
                                </p:outputLabel>
                            </p:column>
                        </p:subTable>
                    </p:dataTable>
                </p:panel>

            </p:panel>

        </h:form>
    </ui:define>


</ui:composition>